package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOpertion implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("请输入要查找书的书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        System.out.println("请输入要查找书的作者：");
        String author = scanner.nextLine();

        System.out.println("请输入要查找书的类型：");
        String type = scanner.nextLine();

        System.out.println("请输入要查找书的价格：");
        int price = scanner.nextInt();

        Book book = new Book(name,author,type,price);

        //看这本书是否已经存在
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            if(bookList.getBooks()[i].equals(book)){
                System.out.println(bookList.getBooks()[i].toString());
                return;
            }
        }

        System.out.println("没有该书");
    }
}
